package com.ap.core.business.message.domain.translators;

import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;

import com.ap.core.common.types.InputMessageType;
import com.ap.core.dao.ApMessageDao;
import com.ap.core.dao.OrderPaymentDao;
import com.ap.core.domain.ApMessage;

/**
 * User: Ranjit.Singh
 * Abstract class for Translator<BO>
 */
public abstract class AbstractHeaderTranslator<BO> implements Translator<BO>{

    private ApMessageDao apMessageDao;
    protected OrderPaymentDao orderPaymentDao;

    protected ApMessage populateApEvent(final InputMessageType inputMessageType, final String reconciliationCycleId, final LocalDate reconciliationDate, final String msgId, final LocalDateTime msgTimestamp, final String senderId){
        final ApMessage apMessage = new ApMessage("AP-ID",
                                         inputMessageType,
           inputMessageType.getInputDestinationTypeCode(),
                                                     null,
                inputMessageType.getInputSenderTypeCode(),
                                                 senderId,
                                                      null,
                                                      msgId,
                                                      msgTimestamp,
                                     reconciliationCycleId,
                                        reconciliationDate);
        apMessageDao.persist(apMessage);
        return apMessage;
    }

    public void setApMessageDao(ApMessageDao apMessageDao) {
        this.apMessageDao = apMessageDao;
    }

    public void setOrderPaymentDao(OrderPaymentDao orderPaymentDao) {
        this.orderPaymentDao = orderPaymentDao;
    }
}
